﻿
using System;
using System.Collections;
using System.Threading;
namespace HBase {
    /**
   *┌────────────────────────────────────────────────┐
   *│　描    述：MyConsole                                                    
   *│　作    者：sgj                                              
   *│　版    本：1.0                                              
   *│　创建时间：2021/3/28 10:26:06                        
   *└────────────────────────────────────────────────┘
   **/
    public class MyConsole {
        static Queue q = new Queue();
        static long count = 0;
        public static void addMessage(String message) {
            if( !LoggerCommon.loggerMyConsole ) {
                return;
            }
            count++;
            q.Enqueue(message);
        }
        public static void ConsoleMessage() {
            while( true ) {

                if( q.Count > 1000 ) {
                    q.Clear();
                    Console.WriteLine(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss fff") + "日志太多被抛弃");
                }
                if( q.Count > 0 ) {
                    object v = q.Dequeue();
                    Console.WriteLine(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss fff-") + v.ToString());
                }
                if( count != 0 && count % 1000 == 0 ) {
                    Console.Clear();
                }
                Thread.Sleep(1000);

            }
        }
    }
}
